package org.ccay.core.exception.impl;

import javax.inject.Named;

import org.ccay.core.base.IExecutable;
import org.ccay.core.exception.ApplicationException;
import org.ccay.core.exception.IRunInExceptionBox;
import org.ccay.core.log.ILogger;

/**
 *  
 * 
 * @since 2013-3-22
 */
@Named("logAndThrowBox")
public class LogAndThrowBox implements IRunInExceptionBox {
 
	/* (non-Javadoc)
	 * @see org.ccay.core.exception.IRunInExceptionBox#run(org.ccay.core.base.IExecutable)
	 */
	public void run(ILogger logger, IExecutable executable) throws ApplicationException {
		try{
			executable.execute();
		} catch(ApplicationException ex){
			logger.error(ex);
			throw ex;
		} catch(RuntimeException ex){
			logger.error(ex);
			throw ex;
		} catch(Error ex){
			//记录Error但不处理
			logger.error(ex);
			throw ex;
		}
	}
}
